const Router = require("koa-router");
const { verifyRouter } = require("../utils/jwt");
const tokenRouter = require("./routers/token");
const userRouter = require("./routers/user");
const uploadRouter = require("./routers/upload");

const router = new Router();

router.prefix("/api");

// 注册自定义跨域中间件
router.use(async (ctx, next) => {
  ctx.set("Access-Control-Allow-Origin", "http://localhost:63342");
  await next();
});
router.use("/token", tokenRouter.routes());

// 注册验证token中间件
router.use(verifyRouter);

router.use("/user", userRouter.routes());
router.use("/upload", uploadRouter.routes());

module.exports = router;
